<?php
namespace App\Models\Traits;

trait AppOrdered {      //使模型默认按created_at的desc排序
	protected $orderBy = 'created_at';
	protected $orderDirection = 'desc';

	public function newQuery($ordered = true)
	{
		$query = parent::newQuery();

	    if (empty($ordered)) {
			return $query;
	    }

		return $query->orderBy($this->orderBy, $this->orderDirection);
	}
}
